﻿<php>$meta_title = "流量及销量趋势";</php>
<include file="Public:header" />
<div id="main" class="main" >
    <div class="content">
  <h3 class="heading">淘宝宝贝流量及销量趋势 [ <a href="__URL__">返回列表</a> ]</h3>
<form class="form-horizontal well" method='post' id="form1" action="__URL__/sale_trend">
        渠道 <select id="" name="is_mobile" class="span1">
            <option value="0" <eq name="_REQUEST.is_mobile" value="0">selected</eq>>PC</option>
            <option value="1" <eq name="_REQUEST.is_mobile" value="1">selected</eq>>无线端</option>
        </select>
		店铺
        <select name="order_source_id" class="span2">
            <option value="0">-店铺选择-</option>
            <option value="3" <eq name="_REQUEST.order_source_id" value="3">selected</eq> >京卫</option>
            <option value="5" <eq name="_REQUEST.order_source_id" value="5">selected</eq> >德生堂</option>
            <!--  <option value="7" <eq name="_REQUEST.order_source_id" value="7">selected</eq> >亚洲</option> -->
        </select>
	    宝贝ID<input type="text" class="search-query span2" name="item_id" <notempty name='_REQUEST.item_id'>
		<php>echo 'value="'.urldecode($_REQUEST['item_id']).'"'</php>
		<else/>
		placeholder="product id" </notempty> >
		从<input type="text" class="span2"  name="start_date" onClick="WdatePicker({dateFmt:'yyyy-MM-dd'})" value="<notempty name='_REQUEST.start_date'>{$_REQUEST.start_date}<else/>{:toDate((time()-24*60*60*30),'Y-m-d')}</notempty>">
		到<input type="text" class="span2" onClick="WdatePicker({dateFmt:'yyyy-MM-dd'})" name="end_date" id="end_time" value="<notempty name='_REQUEST.end_date'>{$_REQUEST.end_date}<else/>{:toDate((time()-24*60*60),'Y-m-d')}</notempty>" >
	<input type="submit" class="btn btn-primary input-middle" value="搜  索"> 最多查询一个月的数据
</form>
<div class="row">
    <div class="span4"><img src="{$product.pics_url}_170x170.jpg"></div>
    <div class="span8 offset2">
        <span>宝贝：{$_REQUEST['item_id']}   <a href="http://detail.tmall.com/item.htm?cat_id=dyw&id={:trim($_REQUEST['item_id'])}" target="_blank">{$product.title}</a> </span>
     <span>下架时间：{$product.list_time}</span><br/>
     <span> <a href="__URL__/search_review?order_source_id={$_REQUEST.order_source_id}&item_id={$_REQUEST.item_id}&start_date={$_REQUEST.start_date}&end_date={$_REQUEST.end_date}" target="_blank"  class="btn btn-primary"><i class="icon-question-sign icon-white"></i>搜索诊断</a> </span><br>
     <span><a href="http://lz.taobao.com/#itemflow/tab:1/begin:{$_REQUEST.start_date}/end:{$_REQUEST.end_date}/item:{$_REQUEST.item_id}" target="_blank" class="btn btn-primary">
             <i class="icon-list icon-white"></i> 流量来源明细</a> (查看前请先登录量子统计)</span><br/>
     <span><a href="http://liuliang.taobao.com/beta/seo_detail.html?days={$_REQUEST.start_date}..{$_REQUEST.end_date}&id={$_REQUEST.item_id}" target="_blank" class="btn btn-primary">
        <i class="icon-list icon-white"></i> 引流及成交关键词(PC+无线)</a> (查看前请先登录江湖策)</span>
     <span><a href="http://sycm.sj.tmall.com/goods/effect/itemEffectDetail.htm?itemId={$_REQUEST.item_id}&sycmToken=758735967" target="_blank" class="btn btn-primary">
        <i class="icon-list icon-white"></i> 全景效果分析-转化率+关联销售(PC+无线)</a> (查看前请先登录生意参谋)</span>
    </div>
</div>
 <div id="container" style="width:100%; height:400px;"></div>
<table class="table table-bordered table-striped">
    <tr>
        <th>日期</th>
        <th>浏览量</th>
        <th>访客数</th>
        <th>拍下件数</th>
        <!--<th>拍下金额(虚)</th> -->
        <th>售价</th>
        <th>成交件数</th>
        <th>成交金额</th>
        <th>宝贝收藏量</th>
        <th>转化率</th>
        <th>人均成交件数</th>
    </tr>
    <php> 
       $sum_ipv = 0;
       $sum_iuv = 0;
       $sum_noplot_alipay_auction_num = 0;
       $sum_alipy_trade_amt = 0;
       $count_log = count($trend_data);
    </php>
    <volist name="trend_data" id="log">
    <tr>
        <td>{$log.day}</td>
        <td>{$log.ipv} </td>
        <td>{$log.iuv}</td>
        <td>{$log.gmv_auction_num}</td>
        <!--<td>{$log.noplot_gmv_trade_amt}</td> -->
        <td>{:sprintf("%01.2f",$log['alipay_trade_amt']/$log['alipay_auction_num'])}</td> <!--售价-->
        <td>{$log.alipay_auction_num}</td>
        <td>{$log.alipay_trade_amt}</td>
        <td>{$log.coll}</td>
        <td>{$log.roc}</td>
        <td>{$log.avg_winner_num}</td>
        <php>
        $sum_ipv +=$log['ipv'];
        $sum_iuv += $log['iuv'];
        $sum_noplot_alipay_auction_num += $log['alipay_auction_num'];
        $sum_alipy_trade_amt  += $log['alipay_trade_amt'];
        </php>
    </tr>
    </volist>
    <tr style="color:green">
        <td>总计</td>
        <td>浏览量:{$sum_ipv}</td>
        <td>访客数{$sum_iuv}</td>
        <td></td>
        <td></td>
        <td>成交件数:{$sum_noplot_alipay_auction_num}</td>
        <td>总销售额:{$sum_alipy_trade_amt}</td>
        <td></td>
        <td></td>
        <td></td>
    </tr>
    <tr style="color:red">
        <td>平均</td>
        <td>{:sprintf("%01.2f",($sum_ipv/$count_log))}</td>
        <td>{:sprintf('%01.2f',($sum_iuv/$count_log))}</td>
        <td></td>
        <td>均售价:{:sprintf('%01.2f',($sum_alipy_trade_amt/$sum_noplot_alipay_auction_num))}</td>
        <td>{:sprintf('%01.2f',($sum_noplot_alipay_auction_num/$count_log))}</td>
        <td>{:sprintf('%01.2f',($sum_alipy_trade_amt/$count_log))}</td>
        <td></td>
        <td></td>
        <td></td>
    </tr>
</table>
</div>
</div>
<load href="__PUBLIC__/Js/My97DatePicker/WdatePicker.js" />
<script src="__PUBLIC__/Js/jquery-1.7.2.min.js"></script>
<script src="__PUBLIC__/Js/highcharts.js"></script>
<script  type="text/javascript">
$(function () {
        $('#container').highcharts({
            title: {
                text: '宝贝销量流量趋势图',
                x: -20 //center
            },
            subtitle: {
                text: '{$product.title}',
                x: -20
            },
            xAxis: {
                categories: [<volist name="trend_data" id="date">'{:date('n-j',strtotime($date['day']))}',</volist>]
            },
            yAxis: {
                title: {
                    text: '数值'
                },
                plotLines: [{
                    value: 0,
                    width: 1,
                    color: '#808080'
                }]
            },
            tooltip: {
                valueSuffix: ''
            },
            legend: {
                layout: 'vertical',
                align: 'right',
                verticalAlign: 'middle',
                borderWidth: 0
            },
            series: [{
                name: '浏览量',
                data: [<volist name="trend_data" id="date">{$date.ipv},</volist>]
            }, {
                name: '访客数',
                data: [<volist name="trend_data" id="date">{$date.iuv},</volist>]
            }, {
                name: '支付宝成交件数',
                data: [<volist name="trend_data" id="date">{$date.alipay_auction_num},</volist>]
            } 
            ]
        });
    });
</script>
